enum TaskStatus {
    CREATED, //新创建（即未开始）
    RUNNING, //传输中
    SUSPEND, //已暂停
    CANCEL, //已取消
    COMPLETE, //已完成
}


class FileTask {
    id: string;
    // file: string;
    fileName: string;
    fileSize: number;
    isDir: boolean;
    status: TaskStatus;
    processValue: number;
    startTime?: Date;      //（服务端赋值）消息创建时间
    from?: string;

    constructor(id:string,/*file: string, */fileName: string, fileSize: number, isDir:boolean) {
        this.id = id;
        // this.file = file;
        this.fileName = fileName;
        this.fileSize = fileSize;
        this.isDir = isDir;
        this.status = TaskStatus.CREATED;
        this.processValue = 0;
        this.startTime = new Date();
    }
}

class ChatMsg {
    id: number;
    message: string;
    self: boolean;
    color: string;
    isFail: boolean;
    from: string;

    constructor(message: string, self: boolean, from: string = '') {
        this.id = Date.now();
        this.message = message;
        this.self = self;
        this.color = randomBubbleColor();
        this.from = from;
        this.isFail = false;
    }
}
const randomBubbleColor = ()=>{
    const colors = ['chat-bubble-primary','chat-bubble-secondary','chat-bubble-accent','chat-bubble-neutral','chat-bubble-info','chat-bubble-success','chat-bubble-warning','chat-bubble-error']
    // 生成随机索引并获取元素
    return colors[Math.floor(Math.random() * colors.length)];
}

export {
    TaskStatus,
    FileTask,
    ChatMsg,
}